home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 52 / Amiga Format AFCD52 (Issue 136, May 2000).iso / -serious- / programming / c / icu-1.3.1 / icuapps / locexp / tools / extractstrings.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  2000-02-23  |  2KB  |  51 lines

  1. #!/bin/sh
  2.  
  3. ## (c) 1999 IBM, Inc.
  4. ## this script extracts strings of the form:
  5. ##    FSWF("myTag", "Fallback text for myTag");
  6. ##
  7. ## into the default resource for the project.
  8. ##
  9. ## NOTE:  
  10. ##   - only ONE fswf per line, please.
  11. ##
  12. ##   - make sure the whole FSWF expression (in the source) is on one line
  13. ##
  14. ##   - if you do NOT want a string emitted (for example, if you use
  15. ##      emitResourceFromFile.sh for a large string) then use this in the
  16. ##      source:
  17. ##
  18. ##         FSWF ( /* NOEXTRACT */ "htmlHEAD",
  19. ##            "</HEAD>\r\n<BODY BGCOLOR=\"#FFFFFF\" >\r\n");
  20. ##
  21. ##      The /*NOEXTRACT*/ between the leftparenthesis and the 
  22. ##      doublequote is sufficient to break the matching string below.
  23. ##
  24. ## BUGS
  25. ##      Does not escape characters properly!
  26. ##      Does not respect commented-out FSWF's, much less #ifdefed out ones!
  27. ##      Script NEEDS to be generalized. What about multiple input files? What if you want something other than default_head and default_tail?
  28. ##
  29. ## Note: FSWF means Fetch String with Fallback.   see locexp.c
  30.  
  31. echo "// locexp default file. Generated from locexp.c on `date` on `hostname`"
  32. echo "// It's probably not a good idea to change this file."
  33. echo "// Better to change locexp.c or the DEFAULT.* source files and rebuild."
  34. echo
  35. echo
  36. echo "default {"
  37. echo
  38. fgrep -h 'FSWF("' $* | sed -e 's%.*FSWF("\([^"]*\)",[ ]*"\([^"]*\)".*%   \1  {  "\2"  }%' | sort | uniq
  39. echo 
  40. echo "// Special Cases"
  41. if [ -f default_head.html ]; then
  42.     emitResourceFromFile.sh htmlHEAD iso-8859-1 default_head.html || exit 1
  43. fi
  44.  
  45. if [ -f default_head.html ]; then
  46.     emitResourceFromFile.sh htmlTAIL iso-8859-1 default_tail.html || exit 1
  47. fi
  48. echo
  49. echo
  50. echo "}"
  51. echo